/*编写一个类实现银行账户的概念，包含的属性有“帐号”、“密码”、“存款余额”、“利率”、“最小余额”，
定义封装这些属性的方法。账号要自动生成。编写主类，使用银行账户类，输入、输出3个储户的
上述信息。考虑：哪些属性可以设计成static属性
 */
package Demo;
class BankAccount {

    private int id;//账户
    private String password;//密码
    private int balance;//余额

    public static double InterestRate=0.101;//利率
    public static int MinimumBalance=100;//最小余额
    public static int init=1000001;//第一个账户

    public BankAccount() {
        this.id=init++;//账户自动生成，每多一个用户，账户号加1
    }
    public BankAccount( String password, int balance) {
        this.id = init++;//账户自动生成
        this.password = password;
        this.balance = balance;
    }

    public int getId() {
        return id;
    }

    public String getPassword() {
        return password;
    }

    public int getBalance() {
        return balance;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }
    //获取利率
    public static double getInterestRate() {
        return InterestRate;
    }
    //获取最小余额
    public static int getMinimumBalance() {
        return MinimumBalance;
    }
    //设置利率
    public static void setInterestRate(double interestRate) {
        InterestRate = interestRate;
    }
    //设置最小余额
    public static void setMinimumBalance(int minimumBalance) {
        MinimumBalance = minimumBalance;
    }

    @Override //打印对象
    public String toString() {
        return "BankAccount{" +
                "id=" + id +
                ", password='" + password + '\'' +
                ", balance=" + balance +
                '}';
    }
}
public class TestBankAccount{
public static void main(String[]args){

     BankAccount.getInterestRate();
     BankAccount.getMinimumBalance();
     System.out.println("利率："+BankAccount.getInterestRate());
     System.out.println("最小余额："+BankAccount.getMinimumBalance());
      //重设利率
     BankAccount.setInterestRate(1.12);
     BankAccount.setMinimumBalance(200);
     System.out.println("利率："+BankAccount.getInterestRate());
     System.out.println("最小余额："+BankAccount.getMinimumBalance());

    BankAccount user1=new BankAccount("6545642w&&",1000000);
    BankAccount user2=new BankAccount("844577!@@1",9999999);
    BankAccount user3=new BankAccount("二货@@#@767",8888888);

    System.out.println(user1);
    System.out.println(user2);
    System.out.println(user3);





  }
}


